package com.qjd.girl.controller;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.web.bind.annotation.*;

@RestController
public class HelloController {

    @Value("${content}")
    private String content;

    /**
     * 绑定配置中的值
     * */
    @GetMapping("/hello")
    public String hello() {
        return content;
    }

    /**
     * 获取url中的数据
     * */
    @RequestMapping(value = "/pathVariable/{id}", method = RequestMethod.GET)
    public String pathVariable(@PathVariable(value = "id") Integer id) {
        return "id is " + id;
    }

    /**
     * 获取请求参数的值
     * get, post 都可以
     */
    @RequestMapping(value = "/requestParam")
    public String requestParam(@RequestParam("id") Integer id) {
        return "id is " + id;
    }

    /**
     * 组合注解
     */
    @GetMapping("/getMapping")
    public String getMapping(@RequestParam("id") Integer id) {
        return "id is " + id;
    }

    /**
     * 组合注解
     */
    @PostMapping("/postMapping")
    public String postMapping(Integer id) {
        return "id is " + id;
    }
}
